package com.open.capacity.paper.feign.impl;

import com.open.capacity.common.auth.details.LoginAppUser;
import com.open.capacity.common.model.SysRole;
import com.open.capacity.paper.feign.UserFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @author liangd
 * @since 2021-02-03 17:37
 */
@Slf4j
public class UserFeignClientFallback implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public LoginAppUser findByUsername(String username) {
                log.error("user-center服务异常" + throwable);
                return new LoginAppUser();
            }

            @Override
            public SysRole findById(Long id) {
                log.error("user-center服务异常" + throwable);
                return new SysRole();
            }
        };
    }
}
